<?php
namespace Admin\Controller;
use Think\Controller;
class AdminController extends Controller {
	//初始化
    public function _initialize(){
		$this->system_name    = C('system_name');
		$this->system_edition = C('edition');
		$this->assign('system_name',$this->system_name);
		$this->assign('system_edition',$this->system_edition);
		self::_isLogin();
    }
	//验证登录
	protected function _isLogin(){
		$admin_user = cookie('z_admin_user');
		if(empty($admin_user)){
			$this->redirect('login/index');
		}else{
			//查询管理员信息
			$userModel = D('user');
			$this->admin_user = $userModel->getUserInfo('',$admin_user['user_id']);
			$this->assign('admin_user',$this->admin_user);
			$this->template = 'Default';
		}
	}

	public function upload_file(){
		$config_filename = APP_PATH.'Admin/Conf/config.json';
		$CONFIG = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents($config_filename)), true);
		$action = I('get.action');
		switch ($action) {
			case 'config':$result =  json_encode($CONFIG);break;
		}
		$this->ajaxReturn($result);
	}
}